using System;
using System.Collections.Generic;
using System.Text;

namespace Eve.Data
{
    public class ControlTowerResource : EveAssociation<Type, Type>
    {
        private int purposeId;
        private int quantity;
        private double minSecurityLevel;
        private int factionId;

        private ControlTowerResourcePurpose purpose;
        private Faction faction;

        public Type ControlTower
        {
            get { return From; }
        }
        public Type Resource
        {
            get { return To; }
        }
        public ControlTowerResourcePurpose Purpose
        {
            get
            {
                if (purpose == null)
                    purpose = new ControlTowerResourcePurpose(db, purposeId);
                return purpose;
            }
        }
        public int Quantity
        {
            get { return quantity; }
        }
        public double MinimumSecurityLevel
        {
            get { return minSecurityLevel; }
        }
        public Faction Faction
        {
            get
            {
                if (faction == null)
                    faction = new Faction(db, factionId);
                return faction;
            }
        }

        internal ControlTowerResource(DbDataRow dr)
            : base(dr.Database, new Type(dr.Database, dr["controlTowerTypeID"]), new Type(dr.Database, dr["resourceTypeID"]))
        {
            Fill(dr);
        }
        internal ControlTowerResource(DbDataRow dr, Type ct)
            : base(dr.Database, ct, new Type(dr.Database, dr["resourceTypeID"]))
        {
            Fill(dr);
        }

        private void Fill(DbDataRow dr)
        {
            purposeId = dr["purpose"];
            quantity = dr["quantity"];
            minSecurityLevel = dr["minSecurityLevel"];
            factionId = dr["factionID"];
        }
    }
}
